<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>返回指定字符之间的字符</title>
  </head>
  <body>
    <script>
      function extractString(source, start, end) {
        const regex = new RegExp(start + "(.*?)" + end, "s");
        const match = source.match(regex); //如果匹配不到，match为 null
        console.log("match", match);
        return match ? match[1] : "";
      }
      const reg = /^\/api\/doc\/download\/\d{9}\/true$/;
      let str = "hhh23146.t45/erterccc";
      let strlast = extractString(str, "hhh", "ccc");
      console.log("提取的字符串：", strlast);

      //如果要在request中的url判断，可以根据match是否为空进行判断是否为当前接口
      let str2 = "/api/doc/download/36355673454/true";
      extractString(str2, "/api/doc/download/", "/true");
    </script>
  </body>
</html>
